package breeze.tool.life.utils;
import java.util.List;
import brz.breeze.app_utils.BAppUtils;
import brz.breeze.web_utils.BWebUtils;
import brz.breeze.service_utils.BExceptionCatcher;
import breeze.tool.life.App;
import org.json.JSONObject;
import org.json.JSONArray;
import java.util.ArrayList;
import brz.breeze.tool_utils.Blog;

public class ExpressInspectionApi {
    
    /*
	*@author BREEZE
	*@date 2021-11-20 22:51:48
    */
    public static final String TAG = "ExpressInspectionApi";
    
	//Api链接
    private static final String API = "https://www.kdcx8.com/auto";
    //Post内容
	private static final String POST = "com=auto&com_name=&pnum=&danhao={danhao}";
	
	private static Blog log;
	
	static{
		log = new Blog(App.getContext());
	}
	
	public static List<String> getContent(String order){
		try{
			String post = POST.replace("{danhao}",order);
			String result = BWebUtils.postWebData(API,post);
			log.i(TAG,result);
			if(result!=null){
				JSONObject obj = new JSONObject(result);
				JSONObject obj3 = obj.getJSONObject("showapi_res_body");
				JSONArray array = obj3.getJSONArray("data");
				List<String> data = new ArrayList<>();
				for(int i = 0;i<array.length();i++){
					JSONObject obj2 = array.getJSONObject(i);
					String context = obj2.getString("context");
					String time = obj2.getString("time");
					data.add(context+"\n"+time);
				}
				return data;
			}
			return null;
		}catch(Exception e){
			BExceptionCatcher.e(App.getContext(),e);
			return null;
		}
	}
	
}
